const Lfy = {
	SetTabarItem(index, text) {
		uni.setTabBarItem({
			index,
			text,
		})
	},
	IsLogin() {
		return uni.getStorageSync('token') || false;
	},
	toMoney(num) {
		num = num.toFixed(2);
		num = parseFloat(num)
		num = num.toLocaleString();
		return num;
	},
	checkMobile(tel) {
		var re = /^1\d{10}$/;
		if (!re.test(tel)) return false;
		return true;
	},
	dateFtt(fmt, date) { //author: meizz  
		date = new Date(date);
		var o = {
			"M+": date.getMonth() + 1, //月份   
			"d+": date.getDate(), //日   
			"h+": date.getHours(), //小时   
			"m+": date.getMinutes(), //分   
			"s+": date.getSeconds(), //秒   
			"q+": Math.floor((date.getMonth() + 3) / 3), //季度   
			"S": date.getMilliseconds() //毫秒   
		};
		if (/(y+)/.test(fmt))
			fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
		for (var k in o)
			if (new RegExp("(" + k + ")").test(fmt))
				fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
		return fmt;
	},
	isEmail(mail) {
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(mail)) {
			return true;
		} else {
			return false;
		}
	},
	IsSupportFile(str) {
		str = str.toLowerCase();
		console.log(str + '--------')
		if (str === 'jpg' || str === 'png' || str === 'tiff' || str === 'tif' || str === 'jpeg' || str === 'ppt' || str ===
			'pptx' || str === 'pptm' || str === 'xls' || str === 'xlsx' || str === 'xlsm' || str === 'doc' || str === 'docx' ||
			str === 'txt' || str === 'docm' || str === 'prn' || str === 'pdf') {
			return true;
		} else return false;
	},
	validateJyh(glhm) { //校验纳税人识别码
		var reg = /^[A-Za-z0-9]{1,30}$/;
		if (!reg.test(glhm)) return false;
		return true;
	},
	launchApp(id) {
		// 判断平台  
		if (plus.os.name == 'Android' || plus.os.name == 'android') {
			plus.runtime.launchApplication({
					pname: id
				},
				function(e) {
					uni.showToast({
						title: "打开失败，可能该手机未安装该app",
						icon: "none"
					})
				}
			);
		} else if (plus.os.name == 'iOS' || plus.os.name == 'ios') {
			plus.runtime.launchApplication({
				action: id
			}, function(e) {
				uni.showToast({
					title: "打开失败，可能该手机未安装该app",
					icon: "none"
				})
			});
		}

	}

}

export default {
	Lfy
}
